# -*- coding: utf-8 -*-
"""
Created on Fri Oct 21 20:13:57 2022

@author: LUO
"""

from ui_testResult import Ui_testResult

from PyQt5 import QtWidgets
from PcrPlotter import PcrPlotter

import sys

class PageTestReuslt(QtWidgets.QWidget, Ui_testResult):
    def __init__(self, parent=None):
        super(PageTestReuslt, self).__init__(parent)
        self.setupUi(self)

        self.PCR1 = PcrPlotter(testCycles=50, size=(600, 400))
        self.PCR1.move(10, 400)

        self.PCR2 = PcrPlotter(testCycles=50, size=(600, 400))
        self.PCR2.move(650, 400)

        self.layoutDown.addWidget(self.PCR1.plt)
        self.layoutDown.addStretch()
        self.layoutDown.addWidget(self.PCR2.plt)

    def clearResult(self):
       self.PCR1.writeCsv(sensor='Sensor1')
       self.PCR2.writeCsv(sensor='Sensor2')
       self.PCR1.clearAllBuffer()
       self.PCR2.clearAllBuffer()
       self.textBrowser.clear()
       self.setVisible(False)


if __name__ == "__main__":
   app = QtWidgets.QApplication(sys.argv)

   page=PageTestReuslt()

   w = QtWidgets.QMainWindow()
   w.setCentralWidget(page)
   w.resize(1280, 800)
   w.show()

   for i in range(0, 50):
      page.PCR1.AddPointToCurve(0, i*0.1)
      page.PCR1.AddPointToCurve(1, i*0.2)
      page.PCR1.AddPointToCurve(2, i*0.3)
      page.PCR1.AddPointToCurve(3, i*0.4)
      page.PCR1.AddPointToCurve(4, i*0.5)
      page.PCR1.AddPointToCurve(5, i*0.6)
      page.PCR1.AddPointToCurve(6, i*0.7)
      page.PCR1.AddPointToCurve(7, i*0.8)
      page.PCR2.AddPointToCurve(0, i*0.1)
      page.PCR2.AddPointToCurve(1, i*0.2)
      page.PCR2.AddPointToCurve(2, i*0.3)
      page.PCR2.AddPointToCurve(3, i*0.4)
      page.PCR2.AddPointToCurve(4, i*0.5)
      #page.PCR2.AddPointToCurve(5, i*0.6)
      page.PCR2.AddPointToCurve(6, i*0.7)
      page.PCR2.AddPointToCurve(7, i*0.8)

   sys.exit(app.exec_())